﻿using ATEC.ATDataCoreNET;
using ATEC.ATDataCoreNET.ATObjects;
using ATEC.GeometryNET;
using ATEC.GeometryNET.Common;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using SZEWAlignmentNet.AlignmentBaseClass;
using System.Collections;
using SSDPNET;
using XJTunnelInterface;
using XJTunnelInterface.DataDefine;
using SZEWTunnelNet.SZEWTunnel.SZEWTunnelInterface;


namespace SZEWTunnelUtilExample
{
    public partial class TunnelTestForm : Form
    {
        public static double CM_To_Uor = 1e2;
        public TunnelTestForm()
        {
            InitializeComponent();
        }
        public static List<string> AllSignatures()
        {
            List<string> R = new List<string>();
            ATScene scene = ATEC.ATCore.Session.Entity.GetActiveATScenes();
            foreach (ATAttachment attachment in scene.GetATAttachments())
            {
                ATProject db = attachment.GetATProject();
                string db_path = db.GetFileName();

                string tag = CollaborateTools.DbGeneralInfo.Peek(db_path).OwnerName;
                R.Add(tag);
            }

            return R;
        }
        /// <summary>
        /// 查询当前场景隧道信息列表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                ATEC.ATDataCoreNET.ATSceneRef scene = SSDPNET.ScenesFunctions.SceneRefGetActive();//当前场景
                ITunnelQueryUtil queryUtil = null;
                List<string> allSignatures = AllSignatures();
                if (allSignatures.Contains("SZEW_Tunnel") || allSignatures.Contains("TunnelControl")) // 隧道的插件标识. 新-旧
                {
                    queryUtil = new SZEWTunnelQueryUtil(scene); //当前场景要参照隧道模型和路线
                    queryUtil.Initialize(); //初始化数据
                }
                else
                {
                    return; // 提前返回
                }


                List<ITunnelInfo> listTunnelInfo = queryUtil.GetAllTunnelSummaryInfo();//查询所有隧道信息

                //打印信息
                foreach (var tunnelInfo in listTunnelInfo)
                {
                    //查询隧道总体信息
                    {
                        SSDPNET.ATDlgFuncs.DialogDmsgsPrint("******************************隧道信息******************************");
                        SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("隧道名称:{0}", tunnelInfo.GetTunnelName().ToString()));
                        SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("隧道距设计线偏移距离:{0}", tunnelInfo.GetOffsetDistance().ToString()));
                        SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("隧道类型:{0}", tunnelInfo.GetTunnelConstructionType().ToString()));
                        SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("公路等级:{0}", tunnelInfo.GetHighwayClassification().ToString()));
                        SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("起点桩号:{0}", tunnelInfo.GetStationRange().GetStart().ToString()));
                        SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("终点桩号:{0}", tunnelInfo.GetStationRange().GetEnd().ToString()));
                        SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("车道数:{0}", tunnelInfo.GetHighwayLaneCount().ToString()));
                        SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("设计时速:{0}", tunnelInfo.GetHighwaySpeed().ToString()));
                        SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("标准路幅宽度:{0}", tunnelInfo.GetStandardRoadWidth().ToString()));
                        SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("行驶类型:{0}", tunnelInfo.GetOneOrTwoWaySegment().ToString()));
                        SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("路线平面线id:{0}", tunnelInfo.GetAlignmentInfo()?.Id.ToString()));
                        SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("是否是左线:{0}", tunnelInfo.IsLeft() == true?"是":"否"));
                        foreach (var item in tunnelInfo.GetLongitudinalSlopeSegInfo())    
                        {
                            SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("隧道纵坡:{0}", item.GetLongSlope().ToString()));
                            SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("隧道纵坡范围:{0}-{1}", item.GetStationRange().GetStart().ToString(), item.GetStationRange().GetEnd().ToString()));
                        }
                    }

                    //查询洞口信息
                    {
                        ITunnelEntranceInfo entranceInfo_S = queryUtil.QueryTunnelEntranceInfo_S(tunnelInfo);
                        if (entranceInfo_S!=null)
                        {
                            SSDPNET.ATDlgFuncs.DialogDmsgsPrint("******************************起点洞口信息******************************");
                            SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("起点洞门类型:{0}", entranceInfo_S.GetTunnelPortalType().ToString()));
                            SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("起点洞口桩号:{0}", entranceInfo_S.GetTunnelEntranceStation().ToString()));
                        }

                        ITunnelEntranceInfo entranceInfo_E = queryUtil.QueryTunnelEntranceInfo_E(tunnelInfo);
                        if (entranceInfo_E != null)
                        {
                            SSDPNET.ATDlgFuncs.DialogDmsgsPrint("*****************************终点洞口信息******************************");
                            SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("起点洞门类型:{0}", entranceInfo_E.GetTunnelPortalType().ToString()));
                            SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("起点洞口桩号:{0}", entranceInfo_E.GetTunnelEntranceStation().ToString()));
                        }
                    }

                    //查询洞身信息
                    {
                        List<ITunnelBodySegInfo> bodySegInfos = queryUtil.QueryTunnelBodySegInfo(tunnelInfo);
                        if (bodySegInfos.Count > 0)
                        {
                            foreach (var segInfo in bodySegInfos)
                            {
                                SSDPNET.ATDlgFuncs.DialogDmsgsPrint("*****************************洞身段信息******************************");
                                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("起点桩号:{0}", segInfo.GetStationRange().GetStart().ToString()));
                                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("终点桩号:{0}", segInfo.GetStationRange().GetEnd().ToString()));
                            }

                        }
                    }

                    //查询停车带信息
                    {
                        List<ITunnelParkingSegInfo> parkingSegInfos = queryUtil.QueryTunnelParkingSegInfo(tunnelInfo);
                        if (parkingSegInfos.Count>0) 
                        {
                            foreach (var segInfo in parkingSegInfos)
                            {
                                SSDPNET.ATDlgFuncs.DialogDmsgsPrint("*****************************停车带段信息******************************");
                                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("起点桩号:{0}", segInfo.GetStartStation().ToString()));
                                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("点桩号:{0}", segInfo.GetEndStation().ToString()));
                                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("起点过渡段长度:{0}", segInfo.GetTransitionSegLength_S().ToString()));
                                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("终点过渡段长度:{0}", segInfo.GetTransitionSegLength_E().ToString()));
                                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("有效段段长度:{0}", segInfo.GetEndStation().ToString()));

                            }

                        }
                    }

                    //查询横洞信息
                    {

                        List<ITunnelCrsChnlInfo> crsChnlInfos = queryUtil.QueryTunnelCrsChnlInfo(tunnelInfo);
                        if (crsChnlInfos.Count > 0)
                        {
                            SSDPNET.ATDlgFuncs.DialogDmsgsPrint("*************************横洞信息*****************************");
                            foreach (var crsInfo in crsChnlInfos)
                            {
                                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("横洞起点桩号：{0}", crsInfo.GetStationRange().GetStart().ToString()));
                                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("横洞终点桩号：{0}", crsInfo.GetStationRange().GetEnd().ToString()));
                                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("横洞类型：{0}", crsInfo.GetTunnelCrsChnlType().ToString()));
                                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("起点隧道名称：{0}", crsInfo.GetTunnelInfo_S().GetTunnelName().ToString()));
                                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("终点隧道名称：{0}", crsInfo.GetTunnelInfo_E().GetTunnelName().ToString()));
                                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("起点主洞桩号：{0}", crsInfo.GetTunnelStation_S().ToString()));
                                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("终点主洞桩号：{0}", crsInfo.GetTunnelStation_E().ToString()));
                                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("横洞宽度：{0}", crsInfo.GetTunnelCrsChnlWidth().ToString()));
                            }
                        }
                    }

                    //查询路面信息
                    {
                        List<ITunnelRoadSegInfo> roadInfoInfos = queryUtil.QueryTunnelRoadInfo(tunnelInfo);
                        if (roadInfoInfos.Count > 0)
                        {
                            SSDPNET.ATDlgFuncs.DialogDmsgsPrint("*************************路面信息*****************************");
                            foreach (var segInfo in roadInfoInfos)
                            {
                                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("起点桩号：{0}", segInfo.GetStationRange().GetStart().ToString()));
                                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("终点桩号：{0}", segInfo.GetStationRange().GetEnd().ToString()));
                                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("路面材料：{0}", segInfo.GetRoadSurfaceMaterialType().ToString()));

                            }
                        }
                    }

                }
                queryUtil.UnInitialize();//卸载数据

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// 查询当前隧道断面信息和水沟信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                ATEC.ATDataCoreNET.ATSceneRef scene = SSDPNET.ScenesFunctions.SceneRefGetActive();
                SZEWTunnelQueryUtil queryUtil = new SZEWTunnelQueryUtil(scene); //当前场景要参照隧道模型和路线
                queryUtil.Initialize();  //初始化数据

                List<ITunnelInfo> listTunnelInfo = queryUtil.GetAllTunnelSummaryInfo();

                //打印每条隧道的桩号断面信息和水沟信息
                foreach (var tunnelInfo in listTunnelInfo)
                {
                    //查询断面信息
                    QueryTunnelSectionInfo(queryUtil,tunnelInfo, tunnelInfo.GetStationRange().GetStart()); //起点桩号处
                    QueryTunnelSectionInfo(queryUtil,tunnelInfo, tunnelInfo.GetStationRange().GetMiddlePoint());//中点桩号
                    QueryTunnelSectionInfo(queryUtil,tunnelInfo, tunnelInfo.GetStationRange().GetEnd());//终点桩号

                    //查询水沟信息
                    QueryTunnelDitchInfo(queryUtil, tunnelInfo, tunnelInfo.GetStationRange().GetStart());
                    QueryTunnelDitchInfo(queryUtil, tunnelInfo, tunnelInfo.GetStationRange().GetMiddlePoint());
                    QueryTunnelDitchInfo(queryUtil, tunnelInfo, tunnelInfo.GetStationRange().GetEnd());
                }

                queryUtil.UnInitialize(); //卸载数据
            }
            catch (Exception ex)
            {
                throw ex;
            }
            
        }


        /// <summary>
        /// 查询隧道断面信息
        /// </summary>
        private void QueryTunnelSectionInfo(SZEWTunnelQueryUtil queryUtil,ITunnelInfo tunnelInfo, double dStation)
        {
            //查询断面信息
            ITunnelSectionInfo sectionInfo = queryUtil.QueryTunnelSectionInfo(tunnelInfo, dStation);
            if (sectionInfo == null) return;

            //断面和设计点
            {
                CurveSet curve = sectionInfo.GetInnerProfile();
                XPoint3d design = sectionInfo.GetDesignPoint();
                ShowCurve(curve, 1);
                ShowPoint(design, 1);

                //断面和设计点变换至路线上
                XTransform3d trans = queryUtil.QueryTunnelTransform(tunnelInfo, dStation);//查询变换矩阵
                curve.Transform(trans);
                XPoint3d newPoint = trans.MultiplyPoint(design.X, design.Y, design.Z);
                ShowCurve(curve, 1);
                ShowPoint(newPoint, 1);
            }


            //查询O1
            {
                ITunnelContourOneArc arc = sectionInfo.GetRing1()?.GetTop_L();//获取拱顶
                if (arc != null)
                {
                    BasicCurve c = arc.ToCurvePrimitive();
                    XEllipse3d xEllipse3D;
                    c.TryGetArc(out xEllipse3D);
                    XPoint3d pt = xEllipse3D.Center;//O1圆心
                    ShowCurve(arc.ToCurveSet(), 3);
                    ShowPoint(pt, 3);
                }
            }


            //行车道中心线
            {
                ITunnelSectionRefLine_LaneCenter lane = sectionInfo.GetRefLine_LaneCenter();
                double offset = lane.GetOffsetToDesignBasis();//基于设计点的偏移值
                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("基于设计点的偏移值:{0}", offset.ToString()));
                CurveSet line = lane.GetLaneCenterLine(); //行车道中线
                ShowCurve(line, 6);
            }


            //基于行车道线，设置左右偏移距离，计算与内轮廓的交点
            {
                //基于行车道中心线左右偏移后和内轮廓的上部交点
                XPoint3d pt1 = sectionInfo.CalcIntersect_Ring1_LaneCenter(-100 * CM_To_Uor);//左侧偏移100cm
                XPoint3d pt2 = sectionInfo.CalcIntersect_Ring1_LaneCenter(100 * CM_To_Uor);//右侧偏移100cm

                ShowPoint(pt1, 1);
                ShowPoint(pt2, 2);
            }


            //查询断面数据
            QueryTunnelSectionDataInfo(sectionInfo, dStation);
        }

        /// <summary>
        /// 查询隧道断面数据信息
        /// </summary>
        private void QueryTunnelSectionDataInfo(ITunnelSectionInfo sectionInfo, double dStation)
        {
            //限界数据
            ITunnelBoundaryPropData boundaryData = sectionInfo.GetBoundaryData();
            {
                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("************************{0}隧道限界数据*******************************", dStation));
                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("限界高度 ：{0}", boundaryData.GetBoundary_H()));
                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("左侧顶角宽度 ：{0}", boundaryData.GetEL()));
                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("右侧顶角宽度 ：{0}", boundaryData.GetER()));
                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("左侧加宽宽度 ：{0}", boundaryData.GetExtraWidth_L()));
                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("右侧加宽宽度 ：{0}", boundaryData.GetExtraWidth_R()));
                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format(" 车道数 ：{0}", boundaryData.GetLaneCount()));
                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("行车道宽度 ,从左往右  ：{0}", boundaryData.GetLaneWidth_L2R()));
                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("人行道高度 ：{0}", boundaryData.GetPaveH()));
                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("左侧人行道宽度 ：{0}", boundaryData.GetPaveWidth_L()));
                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("右侧人行道宽度 ：{0}", boundaryData.GetPaveWidth_R()));
                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("余宽 ：{0}", boundaryData.GetRemainWidth()));
                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("左侧侧向宽度 ：{0}", boundaryData.GetSideWidth_L()));
                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("右侧侧向宽度 ：{0}", boundaryData.GetSideWidth_R()));
            }

            if (sectionInfo.GetSectionParameterizedType() == TunnelSectionParameterizedEnum.Param_1_Center_Radius_Angle) //圆心半径解析方式
            {
                //断面数据
                ITunnelSectionPropData sectionData = sectionInfo.GetSectionData();
                ITunnelSectionPropData_CenterRadiusAngle sectionData_CenterRadiusAngle = sectionData as ITunnelSectionPropData_CenterRadiusAngle;
                if (sectionData_CenterRadiusAngle != null)
                {

                    SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("******************************{0}隧道断面数据******************************", dStation));
                    SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("与限界最距离:{0}", sectionData_CenterRadiusAngle.GetMinDisToBoundary().ToString()));
                    SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("衬砌中心距行车道中心：{0}", sectionData_CenterRadiusAngle.GetDisBetween_LiningCenter_LanesCenter()));
                    SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("距限界底距离：{0}", sectionData_CenterRadiusAngle.GetDis_TopCenter_BoundaryBtm()));
                    SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("内轮廓拱顶圆心角a3：{0}度{1}分{2}秒", sectionData_CenterRadiusAngle.GetInnerFoot_a3().GetDegree(), sectionData_CenterRadiusAngle.GetInnerFoot_a3().GetMinute(), sectionData_CenterRadiusAngle.GetInnerFoot_a3().GetSecond()));
                    SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("内轮廓拱腰半径R3：{0}", sectionData_CenterRadiusAngle.GetInnerFoot_R3()));
                    SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("内轮廓拱顶圆心角a1：{0}度{1}分{2}秒", sectionData_CenterRadiusAngle.GetInnerTop_a1().GetDegree(), sectionData_CenterRadiusAngle.GetInnerTop_a1().GetMinute(), sectionData_CenterRadiusAngle.GetInnerTop_a1().GetSecond()));
                    SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("内轮廓拱顶半径R1：{0}", sectionData_CenterRadiusAngle.GetInnerTop_R1()));
                    SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("内轮廓拱顶圆心角a2：{0}度{1}分{2}秒", sectionData_CenterRadiusAngle.GetInnerWaist_a2().GetDegree(), sectionData_CenterRadiusAngle.GetInnerWaist_a2().GetMinute(), sectionData_CenterRadiusAngle.GetInnerWaist_a2().GetSecond()));
                    SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("内轮廓拱腰半径R2：{0}", sectionData_CenterRadiusAngle.GetInnerWaist_R2()));
                    SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("外轮廓拱脚圆心角a5：{0}度{1}分{2}秒", sectionData_CenterRadiusAngle.GetOuterFoot_a5().GetDegree(), sectionData_CenterRadiusAngle.GetOuterFoot_a5().GetMinute(), sectionData_CenterRadiusAngle.GetOuterFoot_a5().GetSecond()));
                    SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("外轮廓拱脚半径R5：{0}", sectionData_CenterRadiusAngle.GetOuterFoot_R5()));
                    SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("拱脚水平段长度：{0}", sectionData_CenterRadiusAngle.GetOuterFoot_Horizontal_Len()));
                    SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("外轮廓下拱腰圆心角a4：{0}度{1}分{2}秒", sectionData_CenterRadiusAngle.GetOuter_2ndWaist_a4().GetDegree(), sectionData_CenterRadiusAngle.GetOuter_2ndWaist_a4().GetMinute(), sectionData_CenterRadiusAngle.GetOuter_2ndWaist_a4().GetSecond()));
                    SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("单外轮廓下拱腰半径R4：{0}", sectionData_CenterRadiusAngle.GetOuter_2ndWaist_R4()));
                }

            }
            else if (sectionInfo.GetSectionParameterizedType() == TunnelSectionParameterizedEnum.Param_2_TopSpace_CornerDis)//建筑限界解析方式
            {
                //断面数据
                //ITunnelSectionPropData sectionData = sectionInfo.GetSectionData();
                //ITunnelSectionPropData_BoudaryConstraint sectionData_BoudaryConstraint = sectionData as ITunnelSectionPropData_BoudaryConstraint;
                //if (sectionData_BoudaryConstraint != null)
                //{
                //    SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("************************{0}隧道断面数据*******************************", dStation));
                //    SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("中心顶部空间：{0}", sectionData_BoudaryConstraint.GetTopCenter_Space()));
                //    SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("布置长度：{0}", sectionData_BoudaryConstraint.GetPlaceRange()));
                //    SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("与限界最小距离：{0}", sectionData_BoudaryConstraint.GetMinDisToBoundary()));
                //    SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("衬砌中心距行车道中心：{0}", sectionData_BoudaryConstraint.GetDisBetween_LiningCenter_LanesCenter()));
                //    SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("有仰拱时，中心距0的距离：{0}", sectionData_BoudaryConstraint.GetInvert_Arc_CenterLowerThanZero()));
                //    SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("有仰拱时，仰拱开始结束处，水沟所需空间：{0}", sectionData_BoudaryConstraint.GetInvert_Arc_DitchSpace()));
                //    SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("外轮廓第3段弧，顶1腰2此3：{0}", sectionData_BoudaryConstraint.GetOuter_3rd_Arc_R()));
                //    SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("拱脚结束位置，距设计标高0点的距离.  正值往下：{0}", sectionData_BoudaryConstraint.GetOutter_3rd_Arc_Ending_LowerThanZero()));
                //}

            }
        }

        /// <summary>
        /// 查询隧道水沟信息
        /// </summary>
        /// <param name="tunnelInfo"></param>
        /// <param name="dStation"></param>
        private void QueryTunnelDitchInfo(SZEWTunnelQueryUtil queryUtil, ITunnelInfo tunnelInfo, double dStation)
        {
            ITunnelDitchInfo ditchInfo = queryUtil.QueryTunnelDitchInfo(tunnelInfo, dStation);
            if (ditchInfo == null) return;

            //获取电缆沟截面
            {
                CurveSet cableTrenchBackFill_L = ditchInfo.GetProfile_CableTrenchBackFill_L();  //左电缆沟回填截面
                CurveSet cableTrenchBackFill_R = ditchInfo.GetProfile_CableTrenchBackFill_R();  //右电缆沟回填截面

                CurveSet cableTrenchFlank_L = ditchInfo.GetProfile_CableTrenchFlank_L(); //左电缆沟侧墙截面
                CurveSet cableTrenchFlank_R = ditchInfo.GetProfile_CableTrenchFlank_R(); //右电缆沟侧墙截面

                CurveSet cableTrenchCoverPlate_L = ditchInfo.GetProfile_CableTrenchCoverPlate_L();//左盖板截面
                CurveSet cableTrenchCoverPlate_R = ditchInfo.GetProfile_CableTrenchCoverPlate_R();//右盖板截面

                //打印
                ShowCurve(cableTrenchBackFill_L, 1);
                ShowCurve(cableTrenchBackFill_R, 1);
                ShowCurve(cableTrenchFlank_L, 2);
                ShowCurve(cableTrenchFlank_R, 2);
                ShowCurve(cableTrenchCoverPlate_L, 3);
                ShowCurve(cableTrenchCoverPlate_R, 3);
            }


            //获取电缆沟信息
            {
                ITunnelSectionComponentInfo_DLG info_DLG_L = ditchInfo.GetComponentInfo_DLG_L();
                ITunnelSectionComponentInfo_DLG info_DLG_R = ditchInfo.GetComponentInfo_DLG_R();

                SSDPNET.ATDlgFuncs.DialogDmsgsPrint("******************************电缆沟信息******************************");
                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("左侧电缆沟净宽:{0}", info_DLG_L.GetInnerWidth().ToString()));
                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("左侧电缆沟净深:{0}", info_DLG_L.GetInnerDepth().ToString()));
                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("左侧盖板厚度:{0}", info_DLG_L.GetCoverPlateThickness().ToString()));
                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("左侧盖板宽度:{0}", info_DLG_L.GetCoverPlateWidth().ToString()));

                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("右侧电缆沟净宽:{0}", info_DLG_R.GetInnerWidth().ToString()));
                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("右侧电缆沟净深:{0}", info_DLG_R.GetInnerDepth().ToString()));
                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("右侧盖板厚度:{0}", info_DLG_R.GetCoverPlateThickness().ToString()));
                SSDPNET.ATDlgFuncs.DialogDmsgsPrint(String.Format("右侧盖板宽度:{0}", info_DLG_R.GetCoverPlateWidth().ToString()));

            }

            //获取盖板顶部中心点
            {
                XPoint3d coverCenter_L = ditchInfo.GetRefPoint_DLG_CoverCenter_L();
                XPoint3d coverCenter_R = ditchInfo.GetRefPoint_DLG_CoverCenter_R();
                ShowPoint(coverCenter_L, 4);
                ShowPoint(coverCenter_R, 5);
            }


            //基于盖板顶部中心点，设置上下偏移距离，计算和内轮廓交点
            {
                //左侧交点
                XPoint3d p1_L =  queryUtil.QueryIntersect_Ring1_DLG_CoverCenter_L(tunnelInfo, dStation, 100* CM_To_Uor);//x向上偏移100cm
                XPoint3d p2_L = queryUtil.QueryIntersect_Ring1_DLG_CoverCenter_L(tunnelInfo, dStation, 400 * CM_To_Uor);//x向上偏移400cm
                ShowPoint(p1_L, 1);
                ShowPoint(p2_L, 1);

                //右侧交点
                XPoint3d p1_R = queryUtil.QueryIntersect_Ring1_DLG_CoverCenter_R(tunnelInfo, dStation, 100 * CM_To_Uor);//x向上偏移100cm
                XPoint3d p2_R = queryUtil.QueryIntersect_Ring1_DLG_CoverCenter_R(tunnelInfo, dStation, 400 * CM_To_Uor);//x向上偏移400cm
                ShowPoint(p1_R, 2);
                ShowPoint(p2_R, 2);

            }

        }

        /// <summary>
        /// 打印curve
        /// </summary>
        /// <param name="curve"></param>
        /// <param name="colorIndex"></param>
        private void ShowCurve(CurveSet curve, uint colorIndex)
        {
            ATEC.ATDataCoreNET.ATSceneRef scene = SSDPNET.ScenesFunctions.SceneRefGetActive();
            ATObject curveObj = GeometryToATObject.ToObject(scene.GetATScene(), curve, null);
            ObjectPropertiesSetter setter = new ObjectPropertiesSetter();
            setter.SetColor(colorIndex);
            setter.SetWeight(1);
            setter.Apply(curveObj);
            curveObj.AddToScene();

        }

        /// <summary>
        /// 打印poit
        /// </summary>
        /// <param name="point"></param>
        /// <param name="colorIndex"></param>
        private void ShowPoint(XPoint3d point, uint colorIndex)
        {
            ATEC.ATDataCoreNET.ATSceneRef scene = SSDPNET.ScenesFunctions.SceneRefGetActive();
            double len = 1000;
            CurveSet line1 = CurveSet.CreateLinear(new List<XPoint3d>() { point - len * XVector3d.UnitX, point + len * XVector3d.UnitX }, CurveSet.BoundaryType.Open, false);
            CurveSet line2 = CurveSet.CreateLinear(new List<XPoint3d>() { point - len * XVector3d.UnitY, point + len * XVector3d.UnitY }, CurveSet.BoundaryType.Open, false);

            List<CurveSet> curves = new List<CurveSet>() { line1, line2 };
            foreach (var curve in curves)
            {
                ATObject curveObj = GeometryToATObject.ToObject(scene.GetATScene(), curve, null);
                ObjectPropertiesSetter setter = new ObjectPropertiesSetter();
                setter.SetColor(colorIndex);
                setter.SetWeight(1);
                setter.Apply(curveObj);
                curveObj.AddToScene();
            }
        }

        private void TunnelTestForm_Load(object sender, EventArgs e)
        {

        }

       
    }
}
